﻿using System.Globalization;

namespace Common.Helpers
{
    public class HttpParameter
    {
		/// <summary>
		/// 参数名称
		/// </summary>
		public string Name
		{
			get;
			private set;
		}

		/// <summary>
		/// 参数值
		/// </summary>
		public object Value
		{
			get;
			private set;
		}

		/// <summary>
		/// 是否为二进制参数（如图片、文件等）
		/// </summary>
		public bool IsBinaryData
		{
			get;
			private set;
		}

		public string FileName
		{
			get;
			private set;
		}

		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="name">key</param>
		/// <param name="value">value</param>
		public HttpParameter(string name, string value)
		{
			Name = name;
			Value = value;
		}

		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="name">key</param>
		/// <param name="value">value</param>
		public HttpParameter(string name, bool value)
		{
			Name = name;
			Value = (value ? "1" : "0");
		}

		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="name">key</param>
		/// <param name="value">value</param>
		public HttpParameter(string name, int value)
		{
			Name = name;
			Value = value.ToString(CultureInfo.InvariantCulture);
		}

		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="name">key</param>
		/// <param name="value">value</param>
		public HttpParameter(string name, long value)
		{
			Name = name;
			Value = value.ToString(CultureInfo.InvariantCulture);
		}

		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="name">key</param>
		/// <param name="fileName"> </param>
		/// <param name="value">value</param>
		public HttpParameter(string name, string fileName, byte[] value)
		{
			Name = name;
			FileName = fileName;
			Value = value;
			IsBinaryData = true;
		}

		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="name">key</param>
		/// <param name="value">value</param>
		public HttpParameter(string name, object value)
		{
			Name = name;
			Value = value;
		}
	}
}
